﻿// -----------------------------------------------------------------------
// <copyright file="InformationNode.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace VMWareLabWorkflowsDataContracts
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;

    using Microsoft.TeamFoundation.Build.Client;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class AgentInformationNode
    {
        public static readonly string Name = "AgentInformation";

        private IBuildInformationNode _Node;
        public AgentInformationNode(IBuildInformationNode node)
        {
            _Node = node;
        }

        private const string ExceptionMessageKey = "MSTestExceptionMessage";
        public string MSTestExceptionMessage
        {
            get
            {
                return _Node.Fields[ExceptionMessageKey];
            }
            set
            {
                _Node.Fields[ExceptionMessageKey] = value;
            }
        }

        private const string TestFailedKey = "MSTestFailed";
        public bool MSTestFailed
        {
            get
            {
                return bool.Parse(_Node.Fields[TestFailedKey]);
            }
            set
            {
                _Node.Fields[TestFailedKey] = value.ToString(CultureInfo.InvariantCulture);
            }
        }

        public void Save()
        {
            _Node.Save();
        }
    }
}
